package com.qingxin.sms.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qingxin.park.entity.BatchProductsView;
import com.qingxin.sms.entity.SmsQuery;
import com.qingxin.sys.mvc.SysError;
import com.qingxin.sys.service.BaseService;
import com.qingxin.web.service.TraceQueryService;

/**
 * 短信查询
 * @author Administrator
 *
 */
@Service
public class SmsQueryService extends BaseService<SmsQuery, String> {
	
	@Autowired
	private TraceQueryService traceQueryService;
	
	
	/**
	 * 保存
	 * @param smsQuery
	 * @return
	 */
	public SysError add(SmsQuery smsQuery){
		this.save(smsQuery);
		return null;
	}
	
	
	
	/**
	 * 验证追溯码是否有效
	 * @param code
	 * @return
	 */
	public boolean verifyCode(String code){
		if(!code.matches("[0-9]{15}")){
			return false;
		}
		return traceQueryService.verifyCode(code);
	}
	
	
	/**
	 * 获取产品信息
	 * @param pbn
	 * @return
	 */
	public BatchProductsView getBatchProductsView(String pbn){
		BatchProductsView products = (BatchProductsView) getByHql("from BatchProductsView where pbn=? order by createTime desc", pbn);
		return products;
	}
	
	
	
	
}
